package codetop.microsoft.T11;

/**
 * @Author: 18362
 * @Create: 2022-08-16 15:04:30 星期二
 */
class Solution {
    public int maxArea(int[] height) {
        int left = 0, right = height.length-1, res = 0;
        while (left < right) {
            int h = Math.min(height[left], height[right]);
            res = Math.max(res, h * (right - left));
            while (left < right && height[left] <= h)
                ++left;
            while (left < right && height[right] <= h)
                --right;
        }
        return res;
    }
}